Dynomotion

Group: DynoMotion Message: 1628 From: quelisto Date: 8/1/2011
Subject: A couple more questions about RS 232
Hello again Tom, I have few more questions about using RS 232.

First, could you clarify this statement from the file KMotion425\C Programs\RS232BufferedRS232.c :

"
extern char * volatile pRS232RecIn;
extern char * volatile pRS232TxOut;

while (pRS232RecIn == pRS232RecOut); // wait for data in buffer"

As I read it, this while loop is looking to see whether the two pointers refer to the same address...is that correct? So, is it the case that once data arrives, there will be an offset to where one or the other pointer points? Thus are you using the same 256 byte buffer to store both the incoming and outgoing streams, and just dividing it up?

I also don't quite understand the following:

"DoRS232Cmds = FALSE;
// turn off processing RS232 input as commands"


So, what exactly does the function DoRS232Cmds do? Is it intended to be used exclusively with a "remote control" to interpret and then execute commands one line ast a time, kind of like a console?

Finally, when using RS232 GetChar, how do you know when you've reached the end of the buffer and/or the end of the last char stored in a non-full buffer? Or are we to use a carriage return or other similar character to signify the end of a multi-character message?

Thanks!
Group: DynoMotion Message: 1629 From: Tom Kerekes Date: 8/1/2011
Subject: Re: A couple more questions about RS 232
Hi Quelisto,
 
No there are independent receive and transmit buffers.  This line of code:
 
while (pRS232RecIn == pRS232RecOut); // wait for data in buffer"
is with regard to the Receive buffer.  It is a classic circular buffer 1000 characters in size.  There is an Input pointer which is used by the Servo Interrupt to place characters into the buffer (at the head of the list).  There is an Output Pointer which is used by the RS232_GetChar() routine that you will call to remove characters (from the tail of the list).   When the head points to the tail the list is empty.   
 
There are similar pointers for the Transmit (Tx) buffer, but it usually isn't important to know when the Transmit buffer is empty.
 
 
Yes the function:
 
   EnableRS232Cmds(RS232_BAUD_57600);
is used to completely configure the RS232 buffering and switches over KFLOP command processing of console commands coming in and going out USB to RS232.  To completely set up the RS232 buffereing but not switch the processing of commands you must clear that flag.
 
 
With regard to multi-character transmissions that is completely up to you and the device you are controlling.  There is no way the RS232 port can determine how many characters the transmitting device intends to transmit as a message.  You can use the statement above to test if one or more characters have been received, but after you have read all the characters that have been received that is no guarantee that more will not arrive later.  So most protocols use either a fixed length or a terminating character.
 
Regards
TK


--- On Mon, 8/1/11, quelisto <quelisto@...> wrote:

From: quelisto <quelisto@...>
Subject: [DynoMotion] A couple more questions about RS 232
To: DynoMotion@yahoogroups.com
Date: Monday, August 1, 2011, 2:20 PM

 
Hello again Tom, I have few more questions about using RS 232.

First, could you clarify this statement from the file KMotion425\C Programs\RS232BufferedRS232.c :

"
extern char * volatile pRS232RecIn;
extern char * volatile pRS232TxOut;

while (pRS232RecIn == pRS232RecOut); // wait for data in buffer"

As I read it, this while loop is looking to see whether the two pointers refer to the same address...is that correct? So, is it the case that once data arrives, there will be an offset to where one or the other pointer points? Thus are you using the same 256 byte buffer to store both the incoming and outgoing streams, and just dividing it up?

I also don't quite understand the following:

"DoRS232Cmds = FALSE;
// turn off processing RS232 input as commands"

So, what exactly does the function DoRS232Cmds do? Is it intended to be used exclusively with a "remote control" to interpret and then execute commands one line ast a time, kind of like a console?

Finally, when using RS232 GetChar, how do you know when you've reached the end of the buffer and/or the end of the last char stored in a non-full buffer? Or are we to use a carriage return or other similar character to signify the end of a multi-character message?

Thanks!

Group: DynoMotion Message: 1632 From: quelisto Date: 8/2/2011
Subject: Re: A couple more questions about RS 232
Cool, thanks for the info Tom.

I'm sure I'll have a few more questions, but for now that's a big help.